<?php
$this->breadcrumbs = array(
    'Materialrequests' => array('index'),
    'Create',
);

$this->menu = array(
    array('label' => 'List Materialrequest', 'url' => array('index')),
    array('label' => 'Manage Materialrequest', 'url' => array('admin')),
);
?>

<div id="page-heading">
    <h1><?php echo "View Material Request Detail"; ?></h1>
</div>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
    <tr>
        <th rowspan="3" class="sized"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
        <th class="topleft"></th>
        <td id="tbl-border-top">&nbsp;</td>
        <th class="topright"></th>
        <th rowspan="3" class="sized"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
    </tr>
    <tr>
        <td id="tbl-border-left"></td>
        <td>
            <!--  start content-table-inner -->
            <div id="content-table-inner" style="line-height: 30px">

                <table width="50%" border="0" style="text-align: left">
                    <tr>
                        <th width="100">Request date: </th>
                        <td><?php echo date('d-m-Y', strtotime($materialreq->requestdate));?></td>
                        <th width="100">Current status: </th>
                        <td><?php echo ($materialreq->approved) ? "Approved" : "Wating"; ?></td>
                        <?php if (!$materialreq->approved):?>
                        <th width="150">Approve this request: </th>
                        <td><a href="<?php echo CController::createUrl('materialrequest/approveRequest/', array('id' => intval($_GET['id']))); ?>"><img src="<?php echo Yii::app()->theme->baseUrl."/images/approve.ico" ?>" alt="Approve this request" title="Approve this request" /></a></td>
                        <?php endif; ?>
                    </tr>                                                          
                </table>
                <table width="100%" border="1" style="text-align: center" id="product-table">
                    <tr>
                        <th class="table-header-repeat line-left minwidth-1"><a href="" style="background: none">Material Name</a></th>
                        <th class="table-header-repeat line-left minwidth-1"><a href="" style="background: none">Quanitty</a></th>
                        <th class="table-header-repeat line-left minwidth-1"><a href="" style="background: none">Delivered</a></th>
                    </tr>

                    <?php
                    foreach ($materialreqdetail as $detail => $value):
                        ?>
                        <tr>
                            <td><?php echo menuService::getMaterialName($value->materialid); ?></td>
                            <td><?php echo number_format($value->quantity, 0, '', ' '); ?></td>
                            <td><?php echo ($value->delivered) ? "<span class='approved'>Delivered</span>" : "<span class='navigate'>Not Yet</span>";  ?></td>
                        </tr>
                        <?php
                    endforeach;
                    ?>
                    </tr>
                </table>

                <div class="clear"></div>
            </div>
            <!--  end content-table-inner  -->
        </td>
        <td id="tbl-border-right"></td>
    </tr>
    <tr>
        <th class="sized bottomleft"></th>
        <td id="tbl-border-bottom">&nbsp;</td>
        <th class="sized bottomright"></th>
    </tr>
</table>